package h0731;

import java.util.*;

public class Test1 {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
//        int n = sc.nextInt();
//        Set<Integer> set=new HashSet<>();
//        for (int i = 0; i < n; i++) {
//            set.add(sc.nextInt());
//        }
//        List<Integer> ans=new ArrayList<>();
//        ans.addAll(set);
//        Collections.sort(ans);
//        for (Integer an : ans) {
//            System.out.println(an);
//        }

        String s = sc.nextLine().replace("0x", "");
        int sum=0;
        for (int i = 0; i < s.toCharArray().length; i++) {
            char c = s.charAt(i);
            int num=change(c);
            sum=sum*16+num;
        }
        System.out.println(sum);
    }

    private static int change(char c) {
        int ans=0;
        if (Character.isLetter(c)){
            switch (c) {
                case 'A':
                    ans = 10;
                    break;
                case 'B':
                    ans = 11;
                    break;
                case 'C':
                    ans = 12;
                    break;
                case 'D':
                    ans = 13;
                    break;
                case 'E':
                    ans = 14;
                    break;
                case 'F':
                    ans = 15;
                    break;
                default:
                    ans = ans;
                    break;
            }
        }else return c-'0';
        return ans;
    }
}
